def feasible(D, N):
    n = len(D)
    k = [0] * N
    for i in xrange(n):
        k[D[i]] += 1
    for i in xrange(n - 1):
        k[i+1] += k[i]
    for i in xrange(n):
        if k[i] > i: return False
    return True

def task_scheduling(a,d,w):
    N = len(a)
    A = set()
    D = []
    for i in xrange(N):
        if feasible(D + [d[i]], N):
            D.append(d[i])
            A.add(a[i])
    return A

if __name__ == '__main__':
    a = [1,2,3,4,5,6,7]
    d = [4,2,4,3,1,4,6]
    w = [70,60,50,40,30,20,10]
    A = task_scheduling(a, d, w)
    print 'maximum set:', A
